package com.bus.service.impl;

import com.bus.dao.ProviderDao;
import com.bus.entity.Customer;
import com.bus.entity.Provider;
import com.bus.service.ProviderService;
import com.bus.vo.ProviderVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.study.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ProviderServiceImpl implements ProviderService{
    @Autowired
    private ProviderDao providerDao;

    @Override
    public Map<String,Object> selectAllProvider(ProviderVo providerVo) {
        PageHelper.startPage(providerVo.getPage(),providerVo.getLimit());
        List<Provider> providers= providerDao.selectAllProvider(providerVo);
        PageInfo<Provider> pageInfo = new PageInfo<>(providers);
        long total = pageInfo.getTotal();
        Map<String ,Object> map = new HashMap<>();
        map.put("providers",providers);
        map.put("total",total);
        return map;
    }

    @Override
    public int addProvider(ProviderVo providerVo) {
        return providerDao.addProvider(providerVo);
    }

    @Override
    public int updateProvider(ProviderVo providerVo) {
        return providerDao.updateProvider(providerVo);
    }

    @Override
    public int deleteProvider(ProviderVo providerVo) {
        return providerDao.deleteProvider(providerVo);
    }

    @Override
    public List<Provider> selectAll() {
        return providerDao.selectAll();
    }

    @Override
    public List<Provider> selectProviders() {
        return providerDao.selectProviders();
    }
}
